/**********************************************************************************
Name:  BookedAccountSearch
Copyright © 2012  Lodha Group
===================================================================================
===================================================================================
Purpose:
-------
Visualforce page to display filtered Booked account for customer portal users
===================================================================================
===================================================================================
History
-------
VERSION    AUTHOR                DATE             DETAIL              
1.0 -   CG Dev Team          21/05/2012      INITIAL DEVELOPMENT
**********************************************************************************/
public class BookedAccountSearchController {

    public List<accountwrapper> wrapperlist{get;set;}
    public String inputvalue{get;set;}
    public List<Account> accountfilterlist{get;set;}
    Public Boolean Isfiltered{get;set;}
    Public Boolean Isnotfiltered{get;set;}
    
    Public BookedAccountSearchController(){
          
        inputvalue= ApexPages.currentPage().getParameters().get('textvalue');                          
            Searchbyname();                            
    }
    public class accountwrapper{    
            public String Accountid{get;set;}
            public String AccountName{get;set;}
        }
     public void Searchbyname(){
     
         if(inputvalue!=null && inputvalue!=''){
             inputvalue='%'+inputvalue+'%';
             String recordtype='Booked Account';
             String Querystring='Select Id,Name,FirstName,LastName from Account where (Firstname LIKE '+'\''+inputvalue+'\''+' OR LastName Like '+'\''+inputvalue+'\''+') AND(RecordType.Name='+'\''+recordtype+'\''+')'+' AND(IsCustomerPortal!=true)';
             accountfilterlist=Database.Query(Querystring);             
                        
             Isfiltered=true;
             Isnotfiltered=false;
             wrapperlist=new List<accountwrapper>();
          for(Account acc: accountfilterlist)
            {                            
                accountwrapper wrapper=new accountwrapper();
                wrapper.Accountid=acc.Id;
                wrapper.AccountName=acc.Name;
                wrapperlist.add(wrapper);            
            }            
          }
          
          inputvalue=null;
     }
   
   /*public PageReference BookedAccountLoan(){
   
       PageReference pageRef = new PageReference('/apex/BookedAccountHomeLoan');
       pageRef.setRedirect(true);
       return pageRef;
   
   } */ 
     
}